-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp the support for "future incompatible" lints #30787
Conversation
IMO “see *” should be a HELP or HINT.
And this – a warning. |
Can we include the actual URL for issues and PRs? |
OK, as I understand it, this adds additional metadata for future-incompatible lints, resulting in 3 lines displayed, the 'normal' lint message, the future-incompatible explanation with either PR/issue/RFC, and a boilerplate HARD ERROR warning. I'm a bit confused about the exabmple in the OP. It looks to me like it was not generated with the commit in the PR. In particular:
I think the errors described are two separate future-incompatible errors, but the first is an error' and the second is a note which makes me think the two are connected. Based on the code I expected to see an error with no issue number, then an extended note with an error number. Based on what I see here and what I think I understand of this PR I might suggest the following tweak:
Combining the two custom messages reduces duplication. With that and the expanded note for the URL I feel like switching the order of the 'hard error' and url notes. I think it could still be more clear that 1) this is a new error for a pattern that used to be valid, 2) it's breaking is part of an intentional transition strategy. I couldn't come with a simple and clear way to say those though. I do think we should spring for the URL, do everything we can to help hapless users - they may not know where to look for RFCs e.g. |
@brson those messages were indeed generated by this code and are all connected. Right now there 3 pieces:
I agree it's too much. I also had a hard time though trying to pithily explain:
|
So it seems like you are suggesting:
I'd love any suggestions as to good wordings ;) |
@nagisa unfortunately I can't make the "HARD ERROR" part a warning -- or at least not easily -- because the diagnostic builder doesn't support that. You can only append notes, helps, etc. |
Hmm, but that might be easy to change :) |
OK, here is the newer output. For the invalid type parameter case:
For private types in public APIs:
|
☔ The latest upstream changes (presumably #30753) made this pull request unmergeable. Please resolve the merge conflicts. |
Maybe the thing that confused me was the first error message contained an issue number, while the future-incompatible explanation also contained a PR #. The error message issue # I think must have been just hardcoded in the message string, which is weird when compared to the PR # that has its own field in the extended future-incompatible data.
Well, after reading your example again I'm not sure. As you've phrased it it does make sense to have two sentences at least. The first says what the error is, the second says why. I guess what I was thinking was that the 'why' could just be a standard 'this is a future-incompatible error, for more info see...' message and not try to justify it inline. |
I like the new iteration better, I think, but "defaults for type parameters were only intended to be allowed on In this example:
Is this lint emitting an error because of Which brings up the question to me of what happens to these after they do become hard errors. I would hope that they continue carrying this metadata, saying 'this used to work, but doesn't now because {URL}', for those that skipped a few cycles. Here's another attempt at writing the three lines about first error:
It says what the error is (not why); that you aren't crazy, it used to work, but will not work soon; see link for further info. |
format!("defaults for type parameters are only allowed \ | ||
on `struct` or `enum` definitions (see issue #27336)")); | ||
format!("defaults for type parameters were only intended \ | ||
to be allowed on `struct` or `enum` definitions")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct
or enum
?
what about type
, trait
, impl
? They all don't generate the warning currently.
It is an error because of |
seems good. |
true, I will rephrase. |
Do you think it is worth saying when it was changed? Maybe it doesn't matter. |
I am inclined to change the wording of "previously valid Rust" to "previously accepted by the compiler", since frequently these fixes are the results of compiler bugs, and only very infrequently are they a genuine shift in policy. |
eaf533b
to
7098cfd
Compare
OK, revised per suggestions. The current output:
UPDATE: Edited example to use |
(ping @brson to take a look again) |
a0ca6e6
to
0254f69
Compare
I do, but I also want it to be concise. |
@bors r+ |
📌 Commit 0704279 has been approved by |
…nt, r=brson There is now more structure to the report, so that you can specify e.g. an RFC/PR/issue number and other explanatory details. Example message: ``` type-parameter-invalid-lint.rs:14:8: 14:9 error: defaults for type parameters are only allowed on type definitions, like `struct` or `enum` type-parameter-invalid-lint.rs:14 fn avg<T=i32>(_: T) {} ^ type-parameter-invalid-lint.rs:14:8: 14:9 warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! type-parameter-invalid-lint.rs:14:8: 14:9 note: for more information, see PR 30742 <rust-lang#30724> type-parameter-invalid-lint.rs:11:9: 11:28 note: lint level defined here type-parameter-invalid-lint.rs:11 #![deny(future_incompatible)] ^~~~~~~~~~~~~~~~~~~ error: aborting due to previous error ``` r? @brson I would really like feedback also on the specific messages! Fixes rust-lang#30746
There is now more structure to the report, so that you can specify e.g. an RFC/PR/issue number and other explanatory details.
Example message:
r? @brson
I would really like feedback also on the specific messages!
Fixes #30746